home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / umich / falcon / programm.ing / falclib2.lzh / ROUTS / WINDOW.S < prev    next >
Text File  |  1994-08-23  |  5KB  |  219 lines

  1. *
  2. * WINDOW.S
  3. *  (vdilib.i & aeslib.i must be included at the end of the program)
  4. *
  5. *    @createwindow
  6. *
  7. *    Creates a simple gem window. It also initialises the application.
  8. *    The size (xwidth,ywidth) is the workarea of the window.
  9. *
  10. * In    wtype equ %info move full close name
  11. *    xstart,ystart,xwidth,ywidth,windowname(string terminated by 0)
  12. * Out    w_handle,ap_id,screenxmax,screenymax
  13. *    (destroys a lot)
  14. *
  15. *    @recalcwindow
  16. *     Recalculates the window size.
  17. *    (destroys a lot)
  18. *
  19. *    @moveit
  20. *     Moves the window. May be called at every vm_moved(=28) event.
  21. * In     a0.l=adr to messagebuffer
  22. *    (destroys a lot)
  23. *
  24. *    @drawrsrc
  25. *     Draws the rsrc.
  26. *     This function draw doesn't care about clipping, so you should probably not use it.
  27. * In     a0.l=adr to rsrc
  28. *    (destroys a lot)
  29. *
  30. *    @updatersrc
  31. *     Draws the rsrc. Use this when receiving update events(=20).
  32. *     This function takes care of all clipping.
  33. * In     a0.l=adr to rsrc
  34. *    (destroys a lot)
  35. *
  36. *    @topwindow
  37. *     Activates the window. May be called at every vm_topped(=21) event.
  38. * In     a0.l=adr to messagebuffer
  39. *    (destroys a lot)
  40. *
  41. *    @bottomwindow
  42. *     Bottoms the window if it's mine. May be called at every vm_bottomed(=33) event.
  43. * In     a0.l=adr to messagebuffer 
  44. *    (destroys a lot)
  45. *
  46. *    @resizewindow
  47. *     May be called at every resize(=27) event.
  48. * In     a0.l=adr. to messagebuffer
  49. *     (destroys a lot)
  50. *
  51. *    @button
  52. *     Returns the object number that was clicked on. This function may be called
  53. *     at every mousebutton event.
  54. * In     a0.l=adr. to rsrc
  55. *     (It automatically takes the x and y coordinates from int_out)
  56. * Out     d0.w=object that was pressed or -1.
  57. *    (destroys a lot)
  58. *
  59. *    @loadrsrc
  60. *     Loads a resource file and creates a window containg the object in the
  61. *     file. You don't have to call @createwindow if you use @loadrsrc.
  62. * In     wtype equ %info move full close name
  63. *     windowname(string terminated by 0)
  64. *      a0.l=address to a nul terminated filename
  65. * Out     a0.l=address to the resource data
  66. *     (destroys a lot)
  67. *
  68.  
  69.     include    gemmacro.i
  70.  
  71.  
  72. @createwindow
  73.     appl_init
  74.     move.w    d0,ap_id        store the application id
  75.  
  76.     graf_handle
  77.     move.w    d0,current_handle    Desktop's VDI handle
  78.  
  79. * start by opening a virtual workstation
  80.     lea    intin,a0
  81.     moveq    #10-1,d0        -1 for DBF
  82. .fill    move.w    #1,(a0)+        most params are 1
  83.     dbf    d0,.fill
  84.     move.w    #2,(a0)+        use RC system
  85.  
  86.     v_opnvwk            open it
  87.     
  88.     move.l    intout+0,screenxmax    store max x and y coordinates
  89.  
  90. * set the mouse to an arrow
  91.     graf_mouse    #0        arrow please
  92.  
  93.     wind_calc #0,#wtype,xstart,ystart,xwidth,ywidth
  94.     movem.w    int_out+2,d0-d3
  95.     movem.w    d0-d3,xstart
  96.  
  97. * and create the window
  98.     wind_create    #wtype,xstart,ystart,xwidth,ywidth
  99.     move.w    d0,w_handle        save the handle (error checks?)
  100.  
  101. * now set its title
  102.     move.l    #windowname,int_in+4
  103.     wind_set    w_handle,#2    title string
  104.  
  105. * now actually show it by opening
  106.     movem.w    xstart,d0-d3
  107.     wind_open    w_handle,d0,d1,d2,d3
  108.  
  109.     bsr    @recalcwindow
  110.     
  111.     rts
  112.  
  113.  
  114. * calculate the work area of the window
  115. @recalcwindow
  116.     wind_get    w_handle,#4    get work area
  117.     movem.w    int_out+2,d0-d3
  118.     movem.w    d0-d3,xstart
  119.     rts
  120.  
  121. @resizewindow    move    6(a0),d0
  122.         cmp    w_handle,d0
  123.         bne    .ut
  124.         move.l    8(a0),int_in+4
  125.         move.l    12(a0),int_in+8
  126.         wind_set w_handle,#5
  127.         bsr    @recalcwindow
  128. .ut        rts
  129.  
  130. @moveit    
  131.     move.w    6(a0),d0
  132.     cmp.w    w_handle,d0
  133.     bne    .ut            not my window!
  134.     move.w    8(a0),int_in+4        new x pos
  135.     move.w    10(a0),int_in+6        new y pos
  136.     move.w    12(a0),int_in+8        width
  137.     move.w    14(a0),int_in+10    heigth
  138.     wind_set    w_handle,#5
  139.     bsr    @recalcwindow
  140. .ut    rts
  141.  
  142. @drawrsrc    move    xstart,16(a0)
  143.         move    ystart,18(a0)
  144.         objc_draw a0,#0,#10,xstart,ystart,xwidth,ywidth
  145.         rts
  146.  
  147. @button        move    xstart,16(a0)
  148.         move    ystart,18(a0)
  149.         objc_find a0,#0,#10,int_out+2,int_out+4
  150.         move    int_out,d0
  151.         rts
  152.  
  153. @updatersrc    move    xstart,16(a0)
  154.         move    ystart,18(a0)
  155.         move.l    a0,a6
  156.         wind_update #1
  157.         wind_get w_handle,#11
  158.         tst.w    int_out+6
  159.         bne    .next
  160.         tst.w    int_out+8
  161.         beq    .out
  162. .next        objc_draw a6,#0,#10,int_out+2,int_out+4,int_out+6,int_out+8
  163.         wind_get w_handle,#12
  164.         tst.w    int_out+6
  165.         bne    .next
  166.         tst.w    int_out+8
  167.         bne    .next
  168. .out        wind_update #0
  169.         rts
  170.         
  171. @topwindow    
  172.         move.w    6(a0),d0
  173.         cmp.w    w_handle,d0
  174.         bne    .ut            not my window!
  175.         wind_set    w_handle,#10
  176. .ut        rts
  177.  
  178. @bottomwindow
  179.         move.w    6(a0),d0
  180.         cmp.w    w_handle,d0
  181.         bne    .ut            not my window!
  182.         wind_set    w_handle,#25
  183. .ut        rts
  184.  
  185. @exitwindow    wind_close    w_handle
  186.         wind_delete    w_handle
  187.         rts
  188.         
  189. @loadrsrc    rsrc_load a0            load & fix resource
  190.         rsrc_gaddr #0,#0        get adr.
  191.         move.l    addr_out,a0
  192.         move.l    a0,-(sp)
  193.         cmp    #32,18(a0)
  194.         bge    .yok
  195.         move    #32,18(a0)
  196. .yok        move.l    16(a0),xstart        window start position
  197.         move.l    20(a0),xwidth        window size
  198.         bsr    @createwindow
  199.         move.l    (sp)+,a0
  200.         rts
  201.  
  202.  
  203.         
  204.  
  205.  
  206. * these have to remain together
  207. screenxmax    ds.w    1
  208. screenymax    ds.w    1
  209. xstart        ds.w    1
  210. ystart        ds.w    1
  211. xwidth        ds.w    1
  212. ywidth        ds.w    1
  213.  
  214. w_handle    ds.w    1
  215. ws_handle    ds.w    1
  216. ap_id        ds.w    1
  217.  
  218.  
  219.